home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / lib / uw_ttype.c < prev   
C/C++ Source or Header  |  1991-01-25  |  1KB  |  53 lines

  1. /*
  2.  *    uw library - uw_ttype
  3.  *
  4.  * Copyright 1986 by John D. Bruner.  All rights reserved.  Permission to
  5.  * copy this program is given provided that the copy is not sold and that
  6.  * this copyright notice is included.
  7.  */
  8. #include <strings.h>
  9. #include "uwlib.h"
  10.  
  11. struct table {
  12.     char        *tname;
  13.     uwtype_t    wtype;
  14. };
  15.  
  16. /* The following table must be sorted */
  17. static struct table table[] = {
  18.     { "aaa-24", UWT_ANSI },
  19.     { "adm3", UWT_ADM31 },
  20.     { "adm31", UWT_ADM31 },
  21.     { "adm3a", UWT_ADM31 },
  22.     { "ansi", UWT_ANSI },
  23.     { "tek", UWT_TEK4010 },
  24.     { "tek4010", UWT_TEK4010 },
  25.     { "tek4012", UWT_TEK4010 },
  26.     { "vt52", UWT_VT52 },
  27. };
  28.  
  29. uwtype_t
  30. uw_ttype(name)
  31. char *name;
  32. {
  33.     register struct table *t, *lo, *hi;
  34.     register int cmp;
  35.  
  36.     /*
  37.      * Map a terminal name string to a UW window emulation type.
  38.      */
  39.     lo = table;
  40.     hi = table + sizeof table / sizeof table[0] - 1;
  41.     while (lo <= hi) {
  42.         t = lo + (hi-lo) / 2;
  43.         cmp = strcmp(name, t->tname);
  44.         if (cmp == 0)
  45.             return(t->wtype);
  46.         if (cmp < 0)
  47.             hi = t-1;
  48.         else
  49.             lo = t+1;
  50.     }
  51.     return(UWT_ADM31);    /* default if no match */
  52. }
  53.